//
//  PopView.m
//  ZZLogistics
//
//  Created by 辰领科技 on 15/11/27.
//  Copyright © 2015年 辰领科技. All rights reserved.
//

#import "PopView.h"
#import "PopViewTableViewCell.h"
@interface PopView ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)void(^complect)(NSInteger index);
@property(nonatomic,strong)UILabel * titleLabel;
@property(nonatomic,strong)UIView * upLine;
@property(nonatomic,strong)UIView * bottomLine;
@property(nonatomic,strong)UIButton * sureButton;
@property(nonatomic,strong)UIButton * cancleButton;
@property(nonatomic,assign)NSInteger sletedIndex;
@property(nonatomic,assign)NSInteger price;
@property(nonatomic,strong)UITextField * priceTextField;
@property(nonatomic,strong)NSArray * IndentInfoArray;
@property(nonatomic,assign)BOOL buttonHidden;
@end
static NSString *cellIdentify = @"PopViewTableViewCell";
@implementation PopView


//违章查询结果  传入  @【用户名，违章情况】 数组
- (instancetype)initWithResultArray:(NSArray *)resultArray{
    self = [super init];
    if (self) {
        self.frame = flexibleFrame(CGRectMake(30, 125, 260, 165), NO);
        self.layer.cornerRadius = 4*VerticalRatio();
       self.titleLabel.text = @"查询结果";
        UILabel * label = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 55, 260, 15), NO)];
        label.font = [UIFont systemFontOfSize:14*VerticalRatio()];
        label.textColor = [UIColor colorWithWhite:0.204 alpha:1.000];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = [NSString stringWithFormat:@"尊敬的%@用户，你查询的车辆在",resultArray[0]];
        
        UILabel * checkLabel = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 80, 260, 15), NO)];
        checkLabel.font = [UIFont systemFontOfSize:14*VerticalRatio()];
        checkLabel.textAlignment = NSTextAlignmentCenter;
        checkLabel.text = resultArray[1];
        checkLabel.textColor = [UIColor colorWithRed:0.906 green:0.153 blue:0.216 alpha:1.000];
        
        self.sureButton.frame = flexibleFrame(CGRectMake(85, 110, 90, 32), NO);
        [self addSubview:self.sureButton];
        [self addSubview:checkLabel];
        [self addSubview:label];
        [self addSubview:self.titleLabel];
        [self addSubview:self.upLine];
    }
return self;
}

//订单未完成报价表   传入  @【用户名，接货人，费用】 数组
- (instancetype)initWithIndentInfoArray:(NSArray *)indentInfoArray {
    self = [super init];
    if (self) {
        self.frame = flexibleFrame(CGRectMake(30, 165, 260, 160), NO);
        self.layer.cornerRadius = 4*VerticalRatio();
        UILabel * label = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(12, 15, 236, 0), NO)];
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:14*VerticalRatio()];
        label.textColor = [UIColor colorWithWhite:0.373 alpha:1.000];
        label.textAlignment = NSTextAlignmentCenter;
        NSString * string = [NSString stringWithFormat:@"尊敬的%@用户,您的订单已指定%@承接,需支付费用为%ld元,请您",indentInfoArray[0],indentInfoArray[1],[indentInfoArray[2]integerValue]];
        NSString * string0 = indentInfoArray[0];
        NSString * string1 = indentInfoArray[1];
        NSString * string2 = indentInfoArray[2];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",string]];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.867 green:0.561 blue:0.000 alpha:1.000] range:NSMakeRange(3,string0.length)];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.867 green:0.561 blue:0.000 alpha:1.000] range:NSMakeRange(13+string0.length,string1.length)];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.906 green:0.267 blue:0.302 alpha:1.000] range:NSMakeRange(22+string0.length+string1.length,string2.length)];
        label.attributedText = str;
        [label sizeToFit];

       
        UILabel * bottomLabel = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(2, 120, 260, 40), NO)];
        bottomLabel.font = [UIFont systemFontOfSize:11*VerticalRatio()];
        bottomLabel.textColor = [UIColor colorWithWhite:0.573 alpha:1.000];
        bottomLabel.textAlignment = NSTextAlignmentCenter;
        NSString * strng3 = [NSString stringWithFormat:@"您的订单信息即将发送给%@,请等待与您联系！！",indentInfoArray[1]];
         NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",strng3]];
         [str1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.867 green:0.561 blue:0.000 alpha:1.000] range:NSMakeRange(11,string1.length)];
        bottomLabel.attributedText = str1;
        
        self.sureButton.frame = flexibleFrame(CGRectMake(85, 70, 90, 32), NO);
        [self addSubview:self.sureButton];
        [self addSubview:self.bottomLine];
        [self addSubview:bottomLabel];
        [self addSubview:label];
    }
    

return self;
}

//车兴找车 给他发货   人人为我下一步    传入title  button的title数组
- (instancetype)initWithTitle:(NSString *)title buttonTitles:(NSArray *)buttonTitles complect:(void(^)(NSInteger index))complect{
    _sletedIndex = 103;
    self = [super init];
    if (self) {
        _complect = complect;
        self.frame = flexibleFrame(CGRectMake(30, 185, 260, 140), NO);
        self.layer.cornerRadius = 4*VerticalRatio();
        self.titleLabel.text = title;
        
        UIButton * choiceButton = [UIButton buttonWithType:UIButtonTypeCustom];
        choiceButton.frame = flexibleFrame(CGRectMake(15, 73, 110, 40), NO);
        choiceButton.backgroundColor = [UIColor whiteColor];
        choiceButton.layer.borderWidth = 1;
        choiceButton.layer.borderColor = [UIColor colorWithWhite:0.816 alpha:1.000].CGColor;

        [choiceButton setTitleColor:[UIColor colorWithWhite:0.420 alpha:1.000] forState:UIControlStateNormal];
        [choiceButton setTitle:buttonTitles[0] forState:UIControlStateNormal];
        choiceButton.layer.cornerRadius = 4*VerticalRatio();
        choiceButton.titleLabel.font = [UIFont systemFontOfSize:14*VerticalRatio()];
        choiceButton.tag = 102;
        [choiceButton addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        
        UIButton * addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        addButton.frame = flexibleFrame(CGRectMake(135, 73, 110, 40), NO);
        addButton.backgroundColor = [UIColor whiteColor];
        addButton.layer.borderWidth = 1;
        addButton.layer.borderColor = [UIColor colorWithRed:0.855 green:0.482 blue:0.000 alpha:1.000].CGColor;
        [addButton setTitleColor:[UIColor colorWithWhite:0.420 alpha:1.000] forState:UIControlStateNormal];
        [addButton setTitle:buttonTitles[1] forState:UIControlStateNormal];
        addButton.layer.cornerRadius = 4*VerticalRatio();
        addButton.titleLabel.font = [UIFont systemFontOfSize:14*VerticalRatio()];

        addButton.tag = 103;
        [addButton addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        
        self.sureButton.frame = flexibleFrame(CGRectMake(85, 70, 90, 32), NO);
        [self addSubview:self.titleLabel];
        [self addSubview:self.upLine];
        [self addSubview:choiceButton];
        [self addSubview:addButton];

    }
    

return self;
}

//订单详情  报价   传入报价
- (instancetype)initWithComplect:(void(^)(NSInteger index))complect{
    self = [super init];
    if (self) {
        _complect = complect;
        self.frame = flexibleFrame(CGRectMake(30, 185, 260, 140), NO);
        self.layer.cornerRadius = 4*VerticalRatio();
        self.titleLabel.text = @"感想您的参与，请输入您的报价";
        
        UIView * backView = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(25, 72, 210, 35), NO)];
        backView.backgroundColor = [UIColor colorWithRed:0.863 green:0.537 blue:0.075 alpha:1.000];
        backView.layer.cornerRadius = 4*VerticalRatio();
        
        UIView * aheadView = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(1, 1, 120, 33), NO)];
        aheadView.backgroundColor = [UIColor whiteColor];
        aheadView.layer.cornerRadius = 4*VerticalRatio();
        
        UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(95, 11, 20, 15), NO)];
        label.font = [UIFont systemFontOfSize:16*VerticalRatio()];
        label.text = @"元";
        label.textColor = [UIColor colorWithWhite:0.573 alpha:1.000];
        label.textAlignment = NSTextAlignmentCenter;
        
        UITextField * price = [[UITextField alloc]initWithFrame:flexibleFrame(CGRectMake(0, 11, 95, 15), NO)];
        price.keyboardType = UIKeyboardTypeNumberPad;
        price.placeholder = @"请输入报价";
        [price setValue:[UIColor colorWithWhite:0.514 alpha:1.000] forKeyPath:@"_placeholderLabel.textColor"];
        [price setValue:[UIFont systemFontOfSize:14*VerticalRatio()] forKeyPath:@"_placeholderLabel.font"];
        price.textAlignment = NSTextAlignmentCenter;
        _priceTextField = price;
        
        UIButton * sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
        sureButton.frame = flexibleFrame(CGRectMake(120, 0, 90, 35), NO);
        sureButton.tag = 104;
        sureButton.backgroundColor = [UIColor clearColor];
        [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [sureButton setTitle:@"确认提交" forState:UIControlStateNormal];
        [sureButton addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        sureButton.titleLabel.font = [UIFont systemFontOfSize:16*VerticalRatio()];
        
        [self addSubview:backView];
        [backView addSubview:aheadView];
        [aheadView addSubview:label];
        [aheadView addSubview:price];
        [backView addSubview:sureButton];
        [self addSubview:self.upLine];
        [self addSubview:self.titleLabel];
    }
return self;
}

- (instancetype)initWithRecore:(NSInteger)recore Complect:(void (^)(NSInteger))complect{
    self = [super init];
    if (self) {
        _complect = complect;
        self.frame = flexibleFrame(CGRectMake(20, 176, 280, 205), NO);
        self.layer.cornerRadius = 4*VerticalRatio();
        UIButton * sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
        sureButton.frame = flexibleFrame(CGRectMake(57, 145, 166, 33), NO);
        sureButton.tag = 302;
        sureButton.backgroundColor = [UIColor colorWithRed:0.867 green:0.537 blue:0.075 alpha:1.000];
        [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [sureButton setTitle:@"再次兑换" forState:UIControlStateNormal];
        [sureButton addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        sureButton.titleLabel.font = [UIFont systemFontOfSize:16*VerticalRatio()];
        
        UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 75, 280, 15), NO)];
        label.font = [UIFont systemFontOfSize:18*VerticalTexeRatio()];
        label.text = @"恭喜你,兑换成功";
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;

        UIButton * doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        doneButton.frame = flexibleFrame(CGRectMake(130, 38, 20, 20), NO);
        [doneButton setBackgroundImage:[UIImage imageNamed:@"choice1"] forState:UIControlStateNormal];
        
        UIButton * cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        cancelButton.frame = flexibleFrame(CGRectMake(255, 10, 15, 15), NO);
        [cancelButton setBackgroundImage:[UIImage imageNamed:@"coreCancle"] forState:UIControlStateNormal];
        cancelButton.tag = 303;
        [cancelButton addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        cancelButton.titleLabel.font = [UIFont systemFontOfSize:16*VerticalRatio()];
        
        
        UILabel * corelabel =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 110, 280, 15), NO)];
        corelabel.font = [UIFont systemFontOfSize:14*VerticalTexeRatio()];
        corelabel.text = [NSString stringWithFormat:@"剩余积分：%ld",recore];
        corelabel.textColor = [UIColor colorWithWhite:0.314 alpha:1.000];
        corelabel.textAlignment = NSTextAlignmentCenter;
        
        [self addSubview:corelabel];
        [self addSubview:cancelButton];
        [self addSubview:doneButton];
        [self addSubview:label];
        [self addSubview:sureButton];
    }
    return self;
}

- (instancetype)initWithPhotoComplect:(void (^)(NSInteger))complect{
    self = [super init];
    if (self) {
        _complect = complect;
        self.frame = flexibleFrame(CGRectMake(30, 175, 260, 155), NO);
        self.layer.cornerRadius = 6*VerticalRatio();
        self.titleLabel.text = @"上传图片";
        self.titleLabel.textColor = [UIColor colorWithRed:0.094 green:0.502 blue:0.976 alpha:1.000];
        
        NSArray * labelArray = @[@"相机拍摄",@"手机相册"];
         NSArray * imageArray = @[@"xiangji",@"tupian"];
        for (int i = 0; i<2; i++) {
            UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(46+i*110, 108, 65, 15), NO)];
            label.font = [UIFont systemFontOfSize:14*VerticalRatio()];
            label.textColor = [UIColor colorWithWhite:0.188 alpha:1.000];
            label.text = labelArray[i];
            label.textAlignment = NSTextAlignmentLeft;
            
            
            UIButton * Button = [UIButton buttonWithType:UIButtonTypeCustom];
            Button.frame = flexibleFrame(CGRectMake(50+i*110, 60, 43, 43), NO);
            Button.tag = 300+i;
            [Button setBackgroundImage:[UIImage imageNamed:imageArray[i]] forState:UIControlStateNormal];
            [Button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:label];
            [self addSubview:Button];
        }
        
        UIButton * Button = [UIButton buttonWithType:UIButtonTypeCustom];
        Button.frame = flexibleFrame(CGRectMake(200, 0, 60, 45), NO);
        [Button setTitle:@"取消" forState:UIControlStateNormal];
        Button.titleLabel.font = [UIFont systemFontOfSize:17*VerticalTexeRatio()];
        [Button setTitleColor:[UIColor colorWithWhite:0.298 alpha:1.000] forState:UIControlStateNormal];
        [Button addTarget:self action:@selector(cancleChose) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:Button];
        [self addSubview:self.upLine];
        [self addSubview:self.titleLabel];
    }
    return self;


}

- (void)cancleChose{
    [self hide];
}

//订单未完成 报价表  传入订单信息数组
- (instancetype)initWithIndetInfoArray:(NSArray *)indetInfoArray buttonHidden:(BOOL)buttonHidden complect:(void(^)(NSInteger index))complect{
    _IndentInfoArray = indetInfoArray;
    self = [super init];
    if (self) {
        _complect = complect;
        _buttonHidden = buttonHidden;
        self.frame = flexibleFrame(CGRectMake(8, 60, 304, 445), NO);
        self.layer.cornerRadius = 4*VerticalRatio();
        self.titleLabel.frame = flexibleFrame(CGRectMake(0, 0 , 304, 44), NO);
        self.titleLabel.text = @"报价表";
        self.upLine.frame = flexibleFrame(CGRectMake(0, 44, 304, 1), NO);
        UITableView * tableview = [[UITableView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 45, 304, 400), NO) style:UITableViewStylePlain];
        tableview.layer.cornerRadius = 4*VerticalRatio();
        tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        tableview.delegate = self;
        tableview.dataSource = self;
        tableview.separatorStyle = NO;

        //注册
        [tableview registerClass:[PopViewTableViewCell class]  forCellReuseIdentifier:cellIdentify];
        [self addSubview:tableview];
        [self addSubview:self.titleLabel];
        [self addSubview:self.upLine];
        

    }
return self;

}

//收藏成功
- (instancetype)initWithCollectSuccessView{
    self = [super init];
    if (self) {
        self.frame = flexibleFrame(CGRectMake(30, 175, 260, 157), NO);
        self.layer.cornerRadius = 6*VerticalRatio();
        
        
        UIImageView * imageView = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(112, 24, 36, 36), NO)];
        imageView.image = [UIImage imageNamed:@"search14"];
        [self addSubview:imageView];
        
        UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 74, 260, 15), NO)];
        label.font = [UIFont systemFontOfSize:16*VerticalTexeRatio()];
        label.textColor = [UIColor colorWithWhite:0.341 alpha:1.000];
        label.text = @"收藏成功";
        label.textAlignment = NSTextAlignmentCenter;
        
        
        UIButton * Button = [UIButton buttonWithType:UIButtonTypeCustom];
        Button.frame = flexibleFrame(CGRectMake(80, 101, 100, 35), NO);
        Button.layer.cornerRadius = 6*VerticalRatio();
        Button.titleLabel.font = [UIFont systemFontOfSize:16*VerticalTexeRatio()];
        [Button setTitleColor: [UIColor colorWithWhite:0.094 alpha:1.000] forState:UIControlStateNormal];
        Button.backgroundColor = [UIColor colorWithRed:1.000 green:0.796 blue:0.086 alpha:1.000];
        [Button setTitle:@"确定" forState:UIControlStateNormal];
        Button.layer.masksToBounds = YES;
        [Button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:label];
        [self addSubview:Button];

    }
    
    return  self;

}

- (instancetype)initWithCommitDiscloseComplect:(void(^)(NSInteger index))complect{
    self = [super init];
    if (self) {
        self.frame = flexibleFrame(CGRectMake(30, 175, 260, 157), NO);
        self.layer.cornerRadius = 6*VerticalRatio();
        self.complect = complect;
        
        UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(20, 35, 228, 0), NO)];
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:15*VerticalTexeRatio()];
        label.textColor = [UIColor colorWithWhite:0.341 alpha:1.000];
        label.text = @"您提交的爆料信息将尽快审核，并在我的爆料中告知你审核结果。";
        [label sizeToFit];
        label.textAlignment = NSTextAlignmentLeft;
        
        
        UIButton * Button = [UIButton buttonWithType:UIButtonTypeCustom];
        Button.frame = flexibleFrame(CGRectMake(80, 95, 100, 35), NO);
        Button.layer.cornerRadius = 6*VerticalRatio();
        Button.tag = 303;
        Button.titleLabel.font = [UIFont systemFontOfSize:16*VerticalTexeRatio()];
        [Button setTitleColor: [UIColor colorWithWhite:0.094 alpha:1.000] forState:UIControlStateNormal];
        Button.backgroundColor = [UIColor colorWithRed:1.000 green:0.796 blue:0.086 alpha:1.000];
        [Button setTitle:@"提交" forState:UIControlStateNormal];
        Button.layer.masksToBounds = YES;
        [Button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:label];
        [self addSubview:Button];
        
    }
    
    return  self;
    

}

//提示登录
- (instancetype)initWithPleaceLoginComplect:(void(^)(NSInteger index))complect{
    self = [super init];
    if (self) {
        self.frame = flexibleFrame(CGRectMake(30, 177, 260, 157), NO);
        self.layer.cornerRadius = 6*VerticalRatio();
        self.complect = complect;
        
        UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 35, 260, 15), NO)];
        label.font = [UIFont systemFontOfSize:22*VerticalTexeRatio()];
        label.textColor = [UIColor colorWithWhite:0.341 alpha:1.000];
        label.text = @"请先登录";
        label.textAlignment = NSTextAlignmentCenter;
        
        NSArray * nameArray = @[@"取消",@"登录"];
        for (int i = 0; i<2; i++) {
            UIButton * Button = [UIButton buttonWithType:UIButtonTypeCustom];
            Button.frame = flexibleFrame(CGRectMake(22+115*i, 85, 100, 35), NO);
            Button.layer.cornerRadius = 6*VerticalRatio();
            Button.tag = 304+i;
            Button.titleLabel.font = [UIFont systemFontOfSize:16*VerticalTexeRatio()];
           
          
            if (i==0) {
                  Button.backgroundColor = [UIColor colorWithRed:1.000 green:0.412 blue:0.412 alpha:1.000];
                [Button setTitleColor: [UIColor whiteColor] forState:UIControlStateNormal];
            }else{
             [Button setTitleColor: [UIColor colorWithWhite:0.094 alpha:1.000] forState:UIControlStateNormal];
                 Button.backgroundColor = [UIColor colorWithRed:1.000 green:0.796 blue:0.086 alpha:1.000];
            }
            [Button setTitle:nameArray[i] forState:UIControlStateNormal];
            Button.layer.masksToBounds = YES;
            [Button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:Button];
        }
      
        
        [self addSubview:label];
        
        
    }
    
    return  self;
}

//选择性别
- (instancetype)initWithChoseSexComplect:(void(^)(NSInteger index))complect{
    self = [super init];
    if (self) {
        self.frame = flexibleFrame(CGRectMake(30, 175, 260, 143), NO);
        self.layer.cornerRadius = 6*VerticalRatio();
        self.complect = complect;
        
        UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(18, 0, 260, 40), NO)];
        label.font = [UIFont systemFontOfSize:16*VerticalTexeRatio()];
        label.textColor = [UIColor colorWithWhite:0.267 alpha:1.000];
        label.text = @"修改性别";
        label.textAlignment = NSTextAlignmentLeft;
             [self addSubview:label];
        NSArray * nameArray = @[@"男",@"女"];
        for (int i = 0; i<2; i++) {
            UILabel * label =[[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(18, 40+50*i, 260, 50), NO)];
            label.font = [UIFont systemFontOfSize:15*VerticalTexeRatio()];
            label.textColor = [UIColor colorWithWhite:0.506 alpha:1.000];
            label.text = nameArray[i];
            label.textAlignment = NSTextAlignmentLeft;
            [self addSubview:label];
            
            UIButton * Button = [UIButton buttonWithType:UIButtonTypeCustom];
            Button.frame = flexibleFrame(CGRectMake(18, 40+50*i, 260, 50), NO);
            Button.tag = 306+i;
            Button.titleLabel.font = [UIFont systemFontOfSize:15*VerticalTexeRatio()];
            [Button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:Button];
            
            UIView * line = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 40+50*i, 260, 1), YES)];
            line.backgroundColor = [UIColor colorWithRed:0.910 green:0.914 blue:0.910 alpha:1.000];
            [self addSubview:line];
        }
        
        
   
        
        
    }
    
    return  self;
}


#pragma mark -- 点击事件

- (void)actionButton:(UIButton *)sender{
      [self hide];
    if (sender.tag == 102 || sender.tag == 103) {
        if (sender.tag ==_sletedIndex) {
              _complect(sender.tag-102);
            return;
        }
        UIButton * button = (UIButton *)[self viewWithTag:_sletedIndex];
        button.layer.borderColor =  [UIColor colorWithWhite:0.816 alpha:1.000].CGColor;
        sender.layer.borderColor =  [UIColor colorWithRed:0.855 green:0.482 blue:0.000 alpha:1.000].CGColor;
        _sletedIndex = sender.tag;
        _complect(sender.tag-102); 
    }else if (sender.tag == 104){
    _complect([_priceTextField.text integerValue]);

    
    }else if (sender.tag>=110 && sender.tag<200){
    
    _complect(sender.tag-110);
       

    } else  if (sender.tag>=200 &&sender.tag<300){//tableView上的button
        _complect(sender.tag-200);
    }else if (sender.tag >=300 && sender.tag<=301){
    _complect(sender.tag-300);
    
    }else if (sender.tag == 302){
        _complect(sender.tag - 2);
    }else if (sender.tag == 303){
        _complect(1);
    }else if (sender.tag>=304&&sender.tag<=305){
    _complect(sender.tag-304);
    }else if (sender.tag>=306&&sender.tag<=307){
        _complect(sender.tag-306);
    }
}


#pragma mark -- TableviewDatasource  delegate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _IndentInfoArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50*VerticalRatio();
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PopViewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentify forIndexPath:indexPath];
    if (!cell) {
        cell = [[PopViewTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentify];
    }
    
//    cell.numberLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row+1];
//    cell.nameLabel.text = _IndentInfoArray[indexPath.row][0];
//    cell.priceLabel.text = [NSString stringWithFormat:@"￥%@",_IndentInfoArray[indexPath.row][1]];
//    cell.timeLabel.text = _IndentInfoArray[indexPath.row][2];
    [cell.numberButton setTitle:[NSString stringWithFormat:@"%ld",indexPath.row+1] forState:UIControlStateNormal];
    cell.nameLabel.text = _IndentInfoArray[indexPath.row][@"nickname"];
    cell.priceLabel.text = [NSString stringWithFormat:@"￥%@",_IndentInfoArray[indexPath.row][@"price"]];

    //计算发布时长
        NSString * string = _IndentInfoArray[indexPath.row][@"createtime"];
    if (string.length==0) {
        cell.timeLabel.text = @"未知";
    }else{
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];//格式化
        [formatter setDateFormat:@"yyyy-MM-dd HH:MM:ss"];
        
        NSString * date =[formatter stringFromDate:[NSDate date]];
        NSInteger mouth = [[date substringWithRange:NSMakeRange(5, 2)] integerValue]-[[string substringWithRange:NSMakeRange(5, 2)]integerValue];
        NSInteger day = [[date substringWithRange:NSMakeRange(8, 2)] integerValue]-[[string substringWithRange:NSMakeRange(8, 2)]integerValue];
        NSInteger hour = [[date substringWithRange:NSMakeRange(11, 2)] integerValue]-[[string substringWithRange:NSMakeRange(11, 2)]integerValue];
        
        if (mouth>=1) {
            cell.timeLabel.text = [NSString stringWithFormat:@"%ld个月前",mouth];
        }else if (day >= 1 && mouth<1){
            cell.timeLabel.text = [NSString stringWithFormat:@"%ld天前",day];
        }else if(hour>=1 && mouth<1 && day<1){
            cell.timeLabel.text = [NSString stringWithFormat:@"%ld小时前",hour];
        }else if(hour<1 && mouth<1 && day<1){
            cell.timeLabel.text = @"刚刚";
        }
    }
    if (_buttonHidden == YES) {
        cell.button.hidden = YES;
    }else{
    cell.button.hidden = NO;
    }
    cell.button.tag = 200+ indexPath.row;
    [cell.button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];

       return cell;
}





#pragma mark -- Getter

- (UIButton *)sureButton{
    if (!_sureButton) {
        _sureButton = ({
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.backgroundColor = [UIColor colorWithRed:0.863 green:0.537 blue:0.075 alpha:1.000];
            [button setTitle:@"确认" forState:UIControlStateNormal];
            button.layer.cornerRadius = 4*VerticalRatio();
            button.titleLabel.font = [UIFont systemFontOfSize:16*VerticalRatio()];
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            button.tag = 101;
            [button addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
            button;
        });
    }
    return _sureButton;
}



- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 0, 260, 44), NO)];
        _titleLabel.font = [UIFont systemFontOfSize:18*VerticalRatio()];
        _titleLabel.textColor = [UIColor colorWithWhite:0.184 alpha:1.000];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}


- (UIView *)upLine{
    if (!_upLine) {
        _upLine = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 44, 260, 1), NO)];
        _upLine.backgroundColor = [UIColor colorWithWhite:0.867 alpha:1.000];
    }
    return _upLine;
}

- (UIView *)bottomLine{
    if (!_bottomLine) {
        _bottomLine = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 120, 260, 1), NO)];
        _bottomLine.backgroundColor = [UIColor colorWithWhite:0.867 alpha:1.000];
    }
    return _bottomLine;

}
@end
